home *** CD-ROM | disk | FTP | other *** search
- Attribute VB_Name = "modResWav"
- 'for comments please e-mail me at o_pereira@hotmail.com
- 'playing a wav using a res file for "vb6 only"
- 'the sndPlaySound function is expecting a string
- 'for the location & name of the wave so since the wave
- 'is in a res file
- 'the LoadResData command will load a specified resource
- 'and return a byte array[a number from 1-255]
- 'of the information that is why you declare the
- 'Global SoundArray() As Byte to hold the array being returned
- 'then you have to change the "ByVal lpszSoundName As String"
- 'to "lpszSoundName As Byte" making the function return Byte type of data
-
- 'this is the declaration found in apiViewer
- 'Public Declare Function sndPlaySound Lib "winmm.dll" Alias "sndPlaySoundA" (ByVal lpszSoundName As String, ByVal uFlags As Long) As Long
-
- 'changed declaration
- Public Declare Function sndPlaySound Lib "winmm.dll" Alias "sndPlaySoundA" (lpszSoundName As Byte, ByVal uFlags As Long) As Long
-
- 'sndPlaySound flag values for uFlags parameter
- Public Const SND_ASYNC = &H1
- Public Const SND_NODEFAULT = &H2
- Public Const SND_MEMORY = &H4
-
- Private SoundArray() As Byte
-
- Public Sub PlayResWav(bResId As Byte, sFormat As String)
-
- 'this is how loadresdata works
- 'LoadResData(index,format)
- 'index = Integer specifying the ID of
- 'the resource to be loaded within the resource file
- 'format = "Type of resource to be loaded" but since its a
- 'wave it would be the name type for this case "CUSTOM"
- 'you can rename it if you like
- 'to make your own resource files use the VB recource editor
- 'in your Add-Ins
- 'for more information on LoadResData or VB Resource Editor
- 'look in your help
-
- SoundArray = LoadResData(bResId, sFormat)
- sndPlaySound SoundArray(0), SND_ASYNC Or SND_NODEFAULT Or SND_MEMORY
-
- End Sub
-